﻿using SelfMadeMillionaire.Core.Entities;
using SelfMadeMillionaire.Core.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SelfMadeMillionaire.DAL.Repositories
{
	public class PublicationRepository : Repository<Publication>, IPublicationRepository
	{
		public PublicationRepository(IUnitOfWork uow)
			: base(uow)
		{
		}

		public override Publication Update(Publication entity)
		{
			var dbEntity = Get(entity.ID);

			dbEntity.Title = entity.Title;
			dbEntity.PdfFileName = entity.PdfFileName;
			dbEntity.ProductType = entity.ProductType;
			dbEntity.ShortText = entity.ShortText;
			dbEntity.ExternalUrl = entity.ExternalUrl;
			dbEntity.HtmlContent = entity.HtmlContent;
			dbEntity.IsShowOnHomePage = entity.IsShowOnHomePage;
            dbEntity.IsShowOnStartPage = entity.IsShowOnStartPage;
			dbEntity.Date = entity.Date;
			dbEntity.IsEducation = entity.IsEducation;
			dbEntity.MinAccessLevel = entity.MinAccessLevel;
            dbEntity.MinAccessLevelOriginal = entity.MinAccessLevelOriginal;

			Commit();

			return dbEntity;
		}
	}
}
